home *** CD-ROM | disk | FTP | other *** search
/ BMUG PD-ROM BV3 / BMUG PD-ROM Version BV3 (CDRM1097900).iso / Telecom / Utilities / Ymodem.text < prev   
Text File  |  1991-12-29  |  65KB  |  3,147 lines

  1. 1 This document is meant to printed on a 66 line/page printer.
  2.  
  3. 2 I’ve included the first page so that you’ll be able to test print it
  4.  
  5. 3 out to make sure the rest of the document comes out currectly. You can
  6.  
  7. 4 then cut the first page out where indicated below. If you’re uploading or
  8.  
  9. 5 spreading this document around, please include this first page. I’ve gone
  10.  
  11. 6 through unbelivable pains in order to make this thing print out right.
  12.  
  13. 7 For those Mac owners who’ve gotten this file instead of the MacWriteII file,
  14.  
  15. 8 use the follwing info to make your task alot simpler.
  16.  
  17. 9 page setup => options / larger print area
  18.  
  19. 10 font = Courier 10
  20.  
  21. 11 line spacing = 0.158” (Format/Paragraph menuitem)
  22.  
  23. 12 top margin = bottom margin = 0.25” (Format/Page menuitem)
  24.  
  25. 13
  26.  
  27. 14
  28.  
  29. 15
  30.  
  31. 16
  32.  
  33. 17
  34.  
  35. 18
  36.  
  37. 19
  38.  
  39. 20
  40.  
  41. 21
  42.  
  43. 22
  44.  
  45. 23
  46.  
  47. 24
  48.  
  49. 25
  50.  
  51. 26
  52.  
  53. 27
  54.  
  55. 28
  56.  
  57. 29
  58.  
  59. 30
  60.  
  61. 31
  62.  
  63. 32
  64.  
  65. 33
  66.  
  67. 34
  68.  
  69. 35
  70.  
  71. 36
  72.  
  73. 37
  74.  
  75. 38
  76.  
  77. 39
  78.  
  79. 40
  80.  
  81. 41
  82.  
  83. 42
  84.  
  85. 43
  86.  
  87. 44
  88.  
  89. 45
  90.  
  91. 46
  92.  
  93. 47
  94.  
  95. 48
  96.  
  97. 49
  98.  
  99. 50
  100.  
  101. 51
  102.  
  103. 52
  104.  
  105. 53
  106.  
  107. 54
  108.  
  109. 55
  110.  
  111. 56
  112.  
  113. 57
  114.  
  115. 58
  116.  
  117. 59
  118.  
  119. 60
  120.  
  121. 61
  122.  
  123. 62
  124.  
  125. 63
  126.  
  127. 64
  128.  
  129. 65
  130.  
  131. 66  ---- THIS IS THE LAST LINE OF THE FIRST PAGE ---
  132.  
  133.  
  134.  
  135.  
  136.                                       - 1 -
  137.  
  138.  
  139.  
  140.  
  141.                          XMODEM/YMODEM PROTOCOL REFERENCE
  142.  
  143.                      A compendium of documents describing the
  144.  
  145.  
  146.                                 XMODEM and YMODEM
  147.  
  148.  
  149.                              File Transfer Protocols
  150.  
  151.  
  152.  
  153.  
  154.  
  155.                       This document was formatted 10-27-87.
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.                              Edited by Chuck Forsberg
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.                      Please distribute as widely as possible.
  179.  
  180.  
  181.                            Questions to Chuck Forsberg
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.                                Omen Technology Inc
  189.  
  190.                           The High Reliability Software
  191.  
  192.                             17505-V Sauvie Island Road
  193.  
  194.                               Portland Oregon 97231
  195.  
  196.                             VOICE: 503-621-3406 :VOICE
  197.  
  198.     Modem (TeleGodzilla): 503-621-3746 Speed 19200(Telebit PEP),2400,1200,300
  199.  
  200.                               CompuServe: 70007,2304
  201.  
  202.                                     GEnie: CAF
  203.  
  204.                         UUCP: …!tektronix!reed!omen!caf
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.                                       - 2 -
  221.  
  222.  
  223.  
  224.  
  225.     1.  TOWER OF BABEL
  226.  
  227.  
  228.     A "YMODEM Tower of Babel" has descended on the microcomputing community
  229.  
  230.     bringing with it confusion, frustration, bloated phone bills, and wasted
  231.  
  232.     man hours.  Sadly, I (Chuck Forsberg) am partly to blame for this mess.
  233.  
  234.  
  235.     As author of the early 1980s batch and 1k XMODEM extensions, I assumed
  236.  
  237.     readers of earlier versions of this document would implement as much of
  238.  
  239.     the YMODEM protocol as their programming skills and computing environments
  240.  
  241.     would permit.  This proved a rather naive assumption as programmers
  242.  
  243.     motivated by competitive pressure implemented as little of YMODEM as
  244.  
  245.     possible.  Some have taken whatever parts of YMODEM that appealed to them,
  246.  
  247.     applied them to MODEM7 Batch, Telink, XMODEM or whatever, and called the
  248.  
  249.     result YMODEM.
  250.  
  251.  
  252.     Jeff Garbers (Crosstalk package development director) said it all: "With
  253.  
  254.     protocols in the public domain, anyone who wants to dink around with them
  255.  
  256.     can go ahead." [1]
  257.  
  258.  
  259.     Documents containing altered examples derived from YMODEM.DOC have added
  260.  
  261.     to the confusion.  In one instance, the heading in YMODEM.DOC's Figure 1
  262.  
  263.     has mutated from "1024 byte Packets" to "YMODEM/CRC File Transfer
  264.  
  265.     Protocol".  None of the XMODEM and YMODEM examples shown in that document
  266.  
  267.     were correct.
  268.  
  269.  
  270.     To put an end to this confusion, we must make "perfectly clear" what
  271.  
  272.     YMODEM stands for, as Ward Christensen defined it in his 1985 coining of
  273.  
  274.     the term.
  275.  
  276.  
  277.     To the majority of you who read, understood, and respected Ward's
  278.  
  279.     definition of YMODEM, I apologize for the inconvenience.
  280.  
  281.  
  282.     1.1  Definitions
  283.  
  284.  
  285.     ARC     ARC is a program that compresses one or more files into an archive
  286.  
  287.             and extracts files from such archives.
  288.  
  289.  
  290.     XMODEM  refers to the file transfer etiquette introduced by Ward
  291.  
  292.             Christensen's 1977 MODEM.ASM program.  The name XMODEM comes from
  293.  
  294.             Keith Petersen's XMODEM.ASM program, an adaptation of MODEM.ASM
  295.  
  296.             for Remote CP/M (RCPM) systems.  It's also called the MODEM or
  297.  
  298.             MODEM2 protocol.  Some who are unaware of MODEM7's unusual batch
  299.  
  300.             file mode call it MODEM7.  Other aliases include "CP/M Users'
  301.  
  302.             Group" and "TERM II FTP 3".  The name XMODEM caught on partly
  303.  
  304.             because it is distinctive and partly because of media interest in
  305.  
  306.  
  307.  
  308.     __________
  309.  
  310.  
  311.      1. Page C/12, PC-WEEK July 12, 1987
  312.  
  313.  
  314.  
  315.  
  316.  
  317.     Chapter 1
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.     X/YMODEM Protocol Reference      10-27-87                                3
  327.  
  328.  
  329.  
  330.  
  331.             bulletin board and RCPM systems where it was accessed with an
  332.  
  333.             "XMODEM" command.  This protocol is supported by every serious
  334.  
  335.             communications program because of its universality, simplicity,
  336.  
  337.             and reasonable performance.
  338.  
  339.  
  340.     XMODEM/CRC replaces XMODEM's 1 byte checksum with a two byte Cyclical
  341.  
  342.             Redundancy Check (CRC-16), giving modern error detection
  343.  
  344.             protection.
  345.  
  346.  
  347.     XMODEM-1k Refers to the XMODEM/CRC protocol with 1024 byte data blocks.
  348.  
  349.  
  350.     YMODEM  Refers to the XMODEM/CRC (optional 1k blocks) protocol with batch
  351.  
  352.             transmission as described below.  In a nutshell, YMODEM means
  353.  
  354.             BATCH.
  355.  
  356.  
  357.     YMODEM-g Refers to the streaming YMODEM variation described below.
  358.  
  359.  
  360.     True YMODEM(TM) In an attempt to sort out the YMODEM Tower of Babel, Omen
  361.  
  362.             Technology has trademarked the term True YMODEM(TM) to represent
  363.  
  364.             the complete YMODEM protocol described in this document, including
  365.  
  366.             pathname, length, and modification date transmitted in block 0.
  367.  
  368.             Please contact Omen Technology about certifying programs for True
  369.  
  370.             YMODEM(TM) compliance.
  371.  
  372.  
  373.     ZMODEM  uses familiar XMODEM/CRC and YMODEM technology in a new protocol
  374.  
  375.             that provides reliability, throughput, file management, and user
  376.  
  377.             amenities appropriate to contemporary data communications.
  378.  
  379.  
  380.     ZOO     Like ARC, ZOO is a program that compresses one or more files into
  381.  
  382.             a "zoo archive".  ZOO supports many different operating systems
  383.  
  384.             including Unix and VMS.
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.     Chapter 1
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.     X/YMODEM Protocol Reference      10-27-87                                4
  419.  
  420.  
  421.  
  422.  
  423.     2.  YMODEM MINIMUM REQUIREMENTS
  424.  
  425.  
  426.     All programs claiming to support YMODEM must meet the following minimum
  427.  
  428.     requirements:
  429.  
  430.  
  431.        + The sending program shall send the pathname (file name) in block 0.
  432.  
  433.  
  434.        + The pathname shall be a null terminated ASCII string as described
  435.  
  436.          below.
  437.  
  438.  
  439.        + The receiving program shall use this pathname for the received file
  440.  
  441.          name, unless explicitly overridden.
  442.  
  443.  
  444.        + The sending program shall use CRC-16 in response to a "C" pathname
  445.  
  446.          nak, otherwise use 8 bit checksum.
  447.  
  448.  
  449.        + The receiving program must accept any mixture of 128 and 1024 byte
  450.  
  451.          blocks within each file it receives.  Sending programs may switch
  452.  
  453.          between 1024 and 128 byte blocks at the end of file(s), and when the
  454.  
  455.          frequency of retransmissions so suggests.
  456.  
  457.  
  458.        + The sending program must not change the length of an unacknowledged
  459.  
  460.          block.
  461.  
  462.  
  463.        + At the end of each file, the sending program shall send EOT up to ten
  464.  
  465.          times until it receives an ACK character.  (This is part of the
  466.  
  467.          XMODEM spec.)
  468.  
  469.  
  470.        + The end of a transfer session shall be signified by a null (empty)
  471.  
  472.          pathname.
  473.  
  474.  
  475.     Programs not meeting all of these requirements are not YMODEM compatible,
  476.  
  477.     and shall not be described as supporting YMODEM.
  478.  
  479.  
  480.     Meeting these MINIMUM requirements does not guarantee reliable file
  481.  
  482.     transfers under stress.  Particular attention is called to XMODEM's single
  483.  
  484.     character supervisory messages that are easily corrupted by transmission
  485.  
  486.     errors.
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.     Chapter 2
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.     X/YMODEM Protocol Reference      10-27-87                                5
  514.  
  515.  
  516.  
  517.  
  518.     3.  WHY YMODEM?
  519.  
  520.  
  521.     Since its development half a decade ago, the Ward Christensen modem
  522.  
  523.     protocol has enabled a wide variety of computer systems to interchange
  524.  
  525.     data.  There is hardly a communications program that doesn't at least
  526.  
  527.     claim to support this protocol.
  528.  
  529.  
  530.     Advances in computing, modems and networking have revealed a number of
  531.  
  532.     weaknesses in the original protocol:
  533.  
  534.  
  535.        + The short block length caused throughput to suffer when used with
  536.  
  537.          timesharing systems, packet switched networks, satellite circuits,
  538.  
  539.          and buffered (error correcting) modems.
  540.  
  541.  
  542.        + The 8 bit arithmetic checksum and other aspects allowed line
  543.  
  544.          impairments to interfere with dependable, accurate transfers.
  545.  
  546.  
  547.        + Only one file could be sent per command.  The file name had to be
  548.  
  549.          given twice, first to the sending program and then again to the
  550.  
  551.          receiving program.
  552.  
  553.  
  554.        + The transmitted file could accumulate as many as 127 extraneous
  555.  
  556.          bytes.
  557.  
  558.  
  559.        + The modification date of the file was lost.
  560.  
  561.  
  562.     A number of other protocols have been developed over the years, but none
  563.  
  564.     have displaced XMODEM to date:
  565.  
  566.  
  567.        + Lack of public domain documentation and example programs have kept
  568.  
  569.          proprietary protocols such as Blast, Relay, and others tightly bound
  570.  
  571.          to the fortunes of their suppliers.
  572.  
  573.  
  574.        + Complexity discourages the widespread application of BISYNC, SDLC,
  575.  
  576.          HDLC, X.25, and X.PC protocols.
  577.  
  578.  
  579.        + Performance compromises and complexity have limited the popularity of
  580.  
  581.          the Kermit protocol, which was developed to allow file transfers in
  582.  
  583.          environments hostile to XMODEM.
  584.  
  585.  
  586.     The XMODEM protocol extensions and YMODEM Batch address some of these
  587.  
  588.     weaknesses while maintaining most of XMODEM's simplicity.
  589.  
  590.  
  591.     YMODEM is supported by the public domain programs YAM (CP/M),
  592.  
  593.     YAM(CP/M-86), YAM(CCPM-86), IMP (CP/M), KMD (CP/M), rz/sz (Unix, Xenix,
  594.  
  595.     VMS, Berkeley Unix, Venix, Xenix, Coherent, IDRIS, Regulus).  Commercial
  596.  
  597.     implementations include MIRROR, and Professional-YAM.[1] Communications
  598.  
  599.  
  600.  
  601.  
  602.  
  603.  
  604.  
  605.  
  606.     Chapter 3
  607.  
  608.  
  609.  
  610.  
  611.  
  612.  
  613.  
  614.  
  615.     X/YMODEM Protocol Reference      10-27-87                                6
  616.  
  617.  
  618.  
  619.  
  620.     programs supporting these extensions have been in use since 1981.
  621.  
  622.  
  623.     The 1k block length (XMODEM-1k) described below may be used in conjunction
  624.  
  625.     with YMODEM Batch Protocol, or with single file transfers identical to the
  626.  
  627.     XMODEM/CRC protocol except for minimal changes to support 1k blocks.
  628.  
  629.  
  630.     Another extension is the YMODEM-g protocol.  YMODEM-g provides batch
  631.  
  632.     transfers with maximum throughput when used with end to end error
  633.  
  634.     correcting media, such as X.PC and error correcting modems, including 9600
  635.  
  636.     bps units by TeleBit, U.S.Robotics, Hayes, Electronic Vaults, Data Race,
  637.  
  638.     and others.
  639.  
  640.  
  641.     To complete this tome, edited versions of Ward Christensen's original
  642.  
  643.     protocol document and John Byrns's CRC-16 document are included for
  644.  
  645.     reference.
  646.  
  647.  
  648.     References to the MODEM or MODEM7 protocol have been changed to XMODEM to
  649.  
  650.     accommodate the vernacular.  In Australia, it is properly called the
  651.  
  652.     Christensen Protocol.
  653.  
  654.  
  655.  
  656.     3.1  Some Messages from the Pioneer
  657.  
  658.  
  659.     #: 130940 S0/Communications 25-Apr-85  18:38:47
  660.  
  661.     Sb: my protocol
  662.  
  663.     Fm: Ward Christensen 76703,302 [2]
  664.  
  665.     To: all
  666.  
  667.  
  668.     Be aware the article[3] DID quote me correctly in terms of the phrases
  669.  
  670.     like "not robust", etc.
  671.  
  672.  
  673.     It was a quick hack I threw together, very unplanned (like everything I
  674.  
  675.     do), to satisfy a personal need to communicate with "some other" people.
  676.  
  677.  
  678.     ONLY the fact that it was done in 8/77, and that I put it in the public
  679.  
  680.     domain immediately, made it become the standard that it is.
  681.  
  682.  
  683.  
  684.  
  685.  
  686.  
  687.  
  688.  
  689.     __________________________________________________________________________
  690.  
  691.  
  692.      1. Available for IBM PC,XT,AT, Unix and Xenix
  693.  
  694.  
  695.      2. Edited for typesetting appearance
  696.  
  697.  
  698.      3. Infoworld April 29 p. 16
  699.  
  700.  
  701.  
  702.  
  703.  
  704.     Chapter 3
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.     X/YMODEM Protocol Reference      10-27-87                                7
  714.  
  715.  
  716.  
  717.  
  718.     I think its time for me to
  719.  
  720.  
  721.     (1) document it; (people call me and say "my product is going to include
  722.  
  723.     it - what can I 'reference'", or "I'm writing a paper on it, what do I put
  724.  
  725.     in the bibliography") and
  726.  
  727.  
  728.     (2) propose an "incremental extension" to it, which might take "exactly"
  729.  
  730.     the form of Chuck Forsberg's YAM protocol.  He wrote YAM in C for CP/M and
  731.  
  732.     put it in the public domain, and wrote a batch protocol for Unix[4] called
  733.  
  734.     rb and sb (receive batch, send batch), which was basically XMODEM with
  735.  
  736.        (a) a record 0 containing filename date time and size
  737.  
  738.        (b) a 1K block size option
  739.  
  740.        (c) CRC-16.
  741.  
  742.  
  743.     He did some clever programming to detect false ACK or EOT, but basically
  744.  
  745.     left them the same.
  746.  
  747.  
  748.     People who suggest I make SIGNIFICANT changes to the protocol, such as
  749.  
  750.     "full duplex", "multiple outstanding blocks", "multiple destinations", etc
  751.  
  752.     etc don't understand that the incredible simplicity of the protocol is one
  753.  
  754.     of the reasons it survived to this day in as many machines and programs as
  755.  
  756.     it may be found in!
  757.  
  758.  
  759.     Consider the PC-NET group back in '77 or so - documenting to beat the band
  760.  
  761.     - THEY had a protocol, but it was "extremely complex", because it tried to
  762.  
  763.     be "all things to all people" - i.e. send binary files on a 7-bit system,
  764.  
  765.     etc.  I was not that "benevolent". I (emphasize > I < ) had an 8-bit UART,
  766.  
  767.     so "my protocol was an 8-bit protocol", and I would just say "sorry" to
  768.  
  769.     people who were held back by 7-bit limitations.  …
  770.  
  771.  
  772.     Block size: Chuck Forsberg created an extension of my protocol, called
  773.  
  774.     YAM, which is also supported via his public domain programs for UNIX
  775.  
  776.     called rb and sb - receive batch and send batch.  They cleverly send a
  777.  
  778.     "block 0" which contains the filename, date, time, and size.
  779.  
  780.     Unfortunately, its UNIX style, and is a bit weird[5] - octal numbers, etc.
  781.  
  782.     BUT, it is a nice way to overcome the kludgy "echo the chars of the name"
  783.  
  784.     introduced with MODEM7.  Further, chuck uses CRC-16 and optional 1K
  785.  
  786.     blocks.  Thus the record 0, 1K, and CRC, make it a "pretty slick new
  787.  
  788.     protocol" which is not significantly different from my own.
  789.  
  790.  
  791.     Also, there is a catchy name - YMODEM.  That means to some that it is the
  792.  
  793.     "next thing after XMODEM", and to others that it is the Y(am)MODEM
  794.  
  795.  
  796.  
  797.     __________
  798.  
  799.  
  800.      4. VAX/VMS versions of these programs are also available.
  801.  
  802.  
  803.      5. The file length, time, and file mode are optional.  The pathname and
  804.  
  805.         file length may be sent alone if desired.
  806.  
  807.  
  808.  
  809.  
  810.  
  811.     Chapter 3
  812.  
  813.  
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.     X/YMODEM Protocol Reference      10-27-87                                8
  821.  
  822.  
  823.  
  824.  
  825.     protocol.  I don't want to emphasize that too much - out of fear that
  826.  
  827.     other mfgrs might think it is a "competitive" protocol, rather than an
  828.  
  829.     "unaffiliated" protocol.  Chuck is currently selling a much-enhanced
  830.  
  831.     version of his CP/M-80 C program YAM, calling it Professional Yam, and its
  832.  
  833.     for the PC - I'm using it right now.  VERY slick!  32K capture buffer,
  834.  
  835.     script, scrolling, previously captured text search, plus built-in commands
  836.  
  837.     for just about everything - directory (sorted every which way), XMODEM,
  838.  
  839.     YMODEM, KERMIT, and ASCII file upload/download, etc.  You can program it
  840.  
  841.     to "behave" with most any system - for example when trying a number for
  842.  
  843.     CIS it detects the "busy" string back from the modem and substitutes a
  844.  
  845.     diff phone # into the dialing string and branches back to try it.
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.  
  865.  
  866.  
  867.  
  868.  
  869.  
  870.  
  871.  
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.     Chapter 3
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.     X/YMODEM Protocol Reference      10-27-87                                9
  900.  
  901.  
  902.  
  903.  
  904.     4.  XMODEM PROTOCOL ENHANCEMENTS
  905.  
  906.  
  907.     This chapter discusses the protocol extensions to Ward Christensen's 1982
  908.  
  909.     XMODEM protocol description document.
  910.  
  911.  
  912.     The original document recommends the user be asked whether to continue
  913.  
  914.     trying or abort after 10 retries.  Most programs no longer ask the
  915.  
  916.     operator whether he wishes to keep retrying.  Virtually all correctable
  917.  
  918.     errors are corrected within the first few retransmissions.  If the line is
  919.  
  920.     so bad that ten attempts are insufficient, there is a significant danger
  921.  
  922.     of undetected errors.  If the connection is that bad, it's better to
  923.  
  924.     redial for a better connection, or mail a floppy disk.
  925.  
  926.  
  927.  
  928.     4.1  Graceful Abort
  929.  
  930.  
  931.     The YAM and Professional-YAM X/YMODEM routines recognize a sequence of two
  932.  
  933.     consecutive CAN (Hex 18) characters without modem errors (overrun,
  934.  
  935.     framing, etc.) as a transfer abort command.  This sequence is recognized
  936.  
  937.     when is waiting for the beginning of a block or for an acknowledgement to
  938.  
  939.     a block that has been sent.  The check for two consecutive CAN characters
  940.  
  941.     reduces the number of transfers aborted by line hits.  YAM sends eight CAN
  942.  
  943.     characters when it aborts an XMODEM, YMODEM, or ZMODEM protocol file
  944.  
  945.     transfer.  Pro-YAM then sends eight backspaces to delete the CAN
  946.  
  947.     characters from the remote's keyboard input buffer, in case the remote had
  948.  
  949.     already aborted the transfer and was awaiting a keyboarded command.
  950.  
  951.  
  952.  
  953.     4.2  CRC-16 Option
  954.  
  955.  
  956.     The XMODEM protocol uses an optional two character CRC-16 instead of the
  957.  
  958.     one character arithmetic checksum used by the original protocol and by
  959.  
  960.     most commercial implementations.  CRC-16 guarantees detection of all
  961.  
  962.     single and double bit errors,  all errors with an odd number of error
  963.  
  964.     bits, all burst errors of length 16 or less, 99.9969% of all 17-bit error
  965.  
  966.     bursts, and 99.9984 per cent of all possible longer error bursts.  By
  967.  
  968.     contrast, a double bit error, or a burst error of 9 bits or more can sneak
  969.  
  970.     past the XMODEM protocol arithmetic checksum.
  971.  
  972.  
  973.     The XMODEM/CRC protocol is similar to the XMODEM protocol, except that the
  974.  
  975.     receiver specifies CRC-16 by sending C (Hex 43) instead of NAK when
  976.  
  977.     requesting the FIRST block.  A two byte CRC is sent in place of the one
  978.  
  979.     byte arithmetic checksum.
  980.  
  981.  
  982.     YAM's c option to the r command enables CRC-16 in single file reception,
  983.  
  984.     corresponding to the original implementation in the MODEM7 series
  985.  
  986.     programs.  This remains the default because many commercial communications
  987.  
  988.     programs and bulletin board systems still do not support CRC-16,
  989.  
  990.     especially those written in Basic or Pascal.
  991.  
  992.  
  993.     XMODEM protocol with CRC is accurate provided both sender and receiver
  994.  
  995.  
  996.  
  997.  
  998.     Chapter 4                                     XMODEM Protocol Enhancements
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.     X/YMODEM Protocol Reference      10-27-87                               10
  1008.  
  1009.  
  1010.  
  1011.  
  1012.     both report a successful transmission.  The protocol is robust in the
  1013.  
  1014.     presence of characters lost by buffer overloading on timesharing systems.
  1015.  
  1016.  
  1017.     The single character ACK/NAK responses generated by the receiving program
  1018.  
  1019.     adapt well to split speed modems, where the reverse channel is limited to
  1020.  
  1021.     ten per cent or less of the main channel's speed.
  1022.  
  1023.  
  1024.     XMODEM and YMODEM are half duplex protocols which do not attempt to
  1025.  
  1026.     transmit information and control signals in both directions at the same
  1027.  
  1028.     time.  This avoids buffer overrun problems that have been reported by
  1029.  
  1030.     users attempting to exploit full duplex asynchronous file transfer
  1031.  
  1032.     protocols such as Blast.
  1033.  
  1034.  
  1035.     Professional-YAM adds several proprietary logic enhancements to XMODEM's
  1036.  
  1037.     error detection and recovery.  These compatible enhancements eliminate
  1038.  
  1039.     most of the bad file transfers other programs make when using the XMODEM
  1040.  
  1041.     protocol under less than ideal conditions.
  1042.  
  1043.  
  1044.  
  1045.     4.3  XMODEM-1k 1024 Byte Block
  1046.  
  1047.  
  1048.     Disappointing throughput downloading from Unix with YMODEM[1] lead to the
  1049.  
  1050.     development of 1024 byte blocks in 1982.  1024 byte blocks reduce the
  1051.  
  1052.     effect of delays from timesharing systems, modems, and packet switched
  1053.  
  1054.     networks on throughput by 87.5 per cent in addition to decreasing XMODEM's
  1055.  
  1056.     per byte overhead 3 per cent on long files.
  1057.  
  1058.  
  1059.     The choice to use 1024 byte blocks is expressed to the sending program on
  1060.  
  1061.     its command line or selection menu.[2] 1024 byte blocks improve throughput
  1062.  
  1063.     in many applications, but some environments cannot accept 1024 byte
  1064.  
  1065.     bursts, especially minicomputers running 19.2kb ports.
  1066.  
  1067.  
  1068.     An STX (02) replaces the SOH (01) at the beginning of the transmitted
  1069.  
  1070.     block to notify the receiver of the longer block length.  The transmitted
  1071.  
  1072.     block contains 1024 bytes of data.  The receiver should be able to accept
  1073.  
  1074.     any mixture of 128 and 1024 byte blocks.  The block number (in the second
  1075.  
  1076.     and third bytes of the block) is incremented by one for each block
  1077.  
  1078.     regardless of the block length.
  1079.  
  1080.  
  1081.     The sender must not change between 128 and 1024 byte block lengths if it
  1082.  
  1083.     has not received a valid ACK for the current block.  Failure to observe
  1084.  
  1085.     this restriction allows transmission errors to pass undetected.
  1086.  
  1087.  
  1088.  
  1089.  
  1090.     __________
  1091.  
  1092.  
  1093.      1. The name hadn't been coined yet, but the protocol was the same.
  1094.  
  1095.  
  1096.      2. See "KMD/IMP Exceptions to YMODEM" below.
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.     Chapter 4                                     XMODEM Protocol Enhancements
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.     X/YMODEM Protocol Reference      10-27-87                               11
  1112.  
  1113.  
  1114.  
  1115.  
  1116.     If 1024 byte blocks are being used, it is possible for a file to "grow" up
  1117.  
  1118.     to the next multiple of 1024 bytes.  This does not waste disk space if the
  1119.  
  1120.     allocation granularity is 1k or greater.  With YMODEM batch transmission,
  1121.  
  1122.     the optional file length transmitted in the file name block allows the
  1123.  
  1124.     receiver to discard the padding, preserving the exact file length and
  1125.  
  1126.     contents.
  1127.  
  1128.  
  1129.     1024 byte blocks may be used with batch file transmission or with single
  1130.  
  1131.     file transmission.  CRC-16 should be used with the k option to preserve
  1132.  
  1133.     data integrity over phone lines.  If a program wishes to enforce this
  1134.  
  1135.     recommendation, it should cancel the transfer, then issue an informative
  1136.  
  1137.     diagnostic message if the receiver requests checksum instead of CRC-16.
  1138.  
  1139.  
  1140.     Under no circumstances may a sending program use CRC-16 unless the
  1141.  
  1142.     receiver commands CRC-16.
  1143.  
  1144.  
  1145.               Figure 1.  XMODEM-1k Blocks
  1146.  
  1147.  
  1148.               SENDER                                  RECEIVER
  1149.  
  1150.                                                       "s -k foo.bar"
  1151.  
  1152.               "foo.bar open x.x minutes"
  1153.  
  1154.                                                       C
  1155.  
  1156.               STX 01 FE Data[1024] CRC CRC
  1157.  
  1158.                                                       ACK
  1159.  
  1160.               STX 02 FD Data[1024] CRC CRC
  1161.  
  1162.                                                       ACK
  1163.  
  1164.               STX 03 FC Data[1000] CPMEOF[24] CRC CRC
  1165.  
  1166.                                                       ACK
  1167.  
  1168.               EOT
  1169.  
  1170.                                                       ACK
  1171.  
  1172.  
  1173.               Figure 2.  Mixed 1024 and 128 byte Blocks
  1174.  
  1175.  
  1176.               SENDER                                  RECEIVER
  1177.  
  1178.                                                       "s -k foo.bar"
  1179.  
  1180.               "foo.bar open x.x minutes"
  1181.  
  1182.                                                       C
  1183.  
  1184.               STX 01 FE Data[1024] CRC CRC
  1185.  
  1186.                                                       ACK
  1187.  
  1188.               STX 02 FD Data[1024] CRC CRC
  1189.  
  1190.                                                       ACK
  1191.  
  1192.               SOH 03 FC Data[128] CRC CRC
  1193.  
  1194.                                                       ACK
  1195.  
  1196.               SOH 04 FB Data[100] CPMEOF[28] CRC CRC
  1197.  
  1198.                                                       ACK
  1199.  
  1200.               EOT
  1201.  
  1202.                                                       ACK
  1203.  
  1204.  
  1205.  
  1206.  
  1207.  
  1208.  
  1209.  
  1210.  
  1211.     Chapter 4                                     XMODEM Protocol Enhancements
  1212.  
  1213.  
  1214.  
  1215.  
  1216.  
  1217.  
  1218.  
  1219.  
  1220.     X/YMODEM Protocol Reference      10-27-87                               12
  1221.  
  1222.  
  1223.  
  1224.  
  1225.     5.  YMODEM Batch File Transmission
  1226.  
  1227.  
  1228.     The YMODEM Batch protocol is an extension to the XMODEM/CRC protocol that
  1229.  
  1230.     allows 0 or more files to be transmitted with a single command.  (Zero
  1231.  
  1232.     files may be sent if none of the requested files is accessible.) The
  1233.  
  1234.     design approach of the YMODEM Batch protocol is to use the normal routines
  1235.  
  1236.     for sending and receiving XMODEM blocks in a layered fashion similar to
  1237.  
  1238.     packet switching methods.
  1239.  
  1240.  
  1241.     Why was it necessary to design a new batch protocol when one already
  1242.  
  1243.     existed in MODEM7?[1] The batch file mode used by MODEM7 is unsuitable
  1244.  
  1245.     because it does not permit full pathnames, file length, file date, or
  1246.  
  1247.     other attribute information to be transmitted.  Such a restrictive design,
  1248.  
  1249.     hastily implemented with only CP/M in mind, would not have permitted
  1250.  
  1251.     extensions to current areas of personal computing such as Unix, DOS, and
  1252.  
  1253.     object oriented systems.  In addition, the MODEM7 batch file mode is
  1254.  
  1255.     somewhat susceptible to transmission impairments.
  1256.  
  1257.  
  1258.     As in the case of single a file transfer, the receiver initiates batch
  1259.  
  1260.     file transmission by sending a "C" character (for CRC-16).
  1261.  
  1262.  
  1263.     The sender opens the first file and sends block number 0 with the
  1264.  
  1265.     following information.[2]
  1266.  
  1267.  
  1268.     Only the pathname (file name) part is required for batch transfers.
  1269.  
  1270.  
  1271.     To maintain upwards compatibility, all unused bytes in block 0 must be set
  1272.  
  1273.     to null.
  1274.  
  1275.  
  1276.     Pathname The pathname (conventionally, the file name) is sent as a null
  1277.  
  1278.          terminated ASCII string.  This is the filename format used by the
  1279.  
  1280.          handle oriented MSDOS(TM) functions and C library fopen functions.
  1281.  
  1282.          An assembly language example follows:
  1283.  
  1284.                                   DB      'foo.bar',0
  1285.  
  1286.          No spaces are included in the pathname.  Normally only the file name
  1287.  
  1288.          stem (no directory prefix) is transmitted unless the sender has
  1289.  
  1290.          selected YAM's f option to send the full pathname.  The source drive
  1291.  
  1292.          (A:, B:, etc.) is not sent.
  1293.  
  1294.  
  1295.          Filename Considerations:
  1296.  
  1297.  
  1298.  
  1299.  
  1300.     __________
  1301.  
  1302.  
  1303.      1. The MODEM7 batch protocol transmitted CP/M FCB bytes f1…f8 and
  1304.  
  1305.         t1…t3 one character at a time.  The receiver echoed these bytes as
  1306.  
  1307.         received, one at a time.
  1308.  
  1309.  
  1310.      2. Only the data part of the block is described here.
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.     Chapter 5                                     XMODEM Protocol Enhancements
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.     X/YMODEM Protocol Reference      10-27-87                               13
  1326.  
  1327.  
  1328.  
  1329.  
  1330.             + File names are forced to lower case unless the sending system
  1331.  
  1332.               supports upper/lower case file names.  This is a convenience for
  1333.  
  1334.               users of systems (such as Unix) which store filenames in upper
  1335.  
  1336.               and lower case.
  1337.  
  1338.  
  1339.             + The receiver should accommodate file names in lower and upper
  1340.  
  1341.               case.
  1342.  
  1343.  
  1344.             + When transmitting files between different operating systems,
  1345.  
  1346.               file names must be acceptable to both the sender and receiving
  1347.  
  1348.               operating systems.
  1349.  
  1350.  
  1351.          If directories are included, they are delimited by /; i.e.,
  1352.  
  1353.          "subdir/foo" is acceptable, "subdir\foo" is not.
  1354.  
  1355.  
  1356.     Length The file length and each of the succeeding fields are optional.[3]
  1357.  
  1358.          The length field is stored in the block as a decimal string counting
  1359.  
  1360.          the number of data bytes in the file.  The file length does not
  1361.  
  1362.          include any CPMEOF (^Z) or other garbage characters used to pad the
  1363.  
  1364.          last block.
  1365.  
  1366.  
  1367.          If the file being transmitted is growing during transmission, the
  1368.  
  1369.          length field should be set to at least the final expected file
  1370.  
  1371.          length, or not sent.
  1372.  
  1373.  
  1374.          The receiver stores the specified number of characters, discarding
  1375.  
  1376.          any padding added by the sender to fill up the last block.
  1377.  
  1378.  
  1379.     Modification Date The mod date is optional, and the filename and length
  1380.  
  1381.          may be sent without requiring the mod date to be sent.
  1382.  
  1383.  
  1384.          Iff the modification date is sent, a single space separates the
  1385.  
  1386.          modification date from the file length.
  1387.  
  1388.  
  1389.          The mod date is sent as an octal number giving the time the contents
  1390.  
  1391.          of the file were last changed, measured in seconds from Jan 1 1970
  1392.  
  1393.          Universal Coordinated Time (GMT).  A date of 0 implies the
  1394.  
  1395.          modification date is unknown and should be left as the date the file
  1396.  
  1397.          is received.
  1398.  
  1399.  
  1400.          This standard format was chosen to eliminate ambiguities arising from
  1401.  
  1402.          transfers between different time zones.
  1403.  
  1404.  
  1405.  
  1406.  
  1407.  
  1408.  
  1409.     __________
  1410.  
  1411.  
  1412.      3. Fields may not be skipped.
  1413.  
  1414.  
  1415.  
  1416.  
  1417.  
  1418.     Chapter 5                                     XMODEM Protocol Enhancements
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.     X/YMODEM Protocol Reference      10-27-87                               14
  1428.  
  1429.  
  1430.  
  1431.  
  1432.     Mode Iff the file mode is sent, a single space separates the file mode
  1433.  
  1434.          from the modification date.  The file mode is stored as an octal
  1435.  
  1436.          string.  Unless the file originated from a Unix system, the file mode
  1437.  
  1438.          is set to 0.  rb(1) checks the file mode for the 0x8000 bit which
  1439.  
  1440.          indicates a Unix type regular file.  Files with the 0x8000 bit set
  1441.  
  1442.          are assumed to have been sent from another Unix (or similar) system
  1443.  
  1444.          which uses the same file conventions.  Such files are not translated
  1445.  
  1446.          in any way.
  1447.  
  1448.  
  1449.  
  1450.     Serial Number Iff the serial number is sent, a single space separates the
  1451.  
  1452.          serial number from the file mode.  The serial number of the
  1453.  
  1454.          transmitting program is stored as an octal string.  Programs which do
  1455.  
  1456.          not have a serial number should omit this field, or set it to 0.  The
  1457.  
  1458.          receiver's use of this field is optional.
  1459.  
  1460.  
  1461.  
  1462.     Other Fields YMODEM was designed to allow additional header fields to be
  1463.  
  1464.          added as above without creating compatibility problems with older
  1465.  
  1466.          YMODEM programs.  Please contact Omen Technology if other fields are
  1467.  
  1468.          needed for special application requirements.
  1469.  
  1470.  
  1471.     The rest of the block is set to nulls.  This is essential to preserve
  1472.  
  1473.     upward compatibility.[4]
  1474.  
  1475.  
  1476.     If the filename block is received with a CRC or other error, a
  1477.  
  1478.     retransmission is requested.  After the filename block has been received,
  1479.  
  1480.     it is ACK'ed if the write open is successful.  If the file cannot be
  1481.  
  1482.     opened for writing, the receiver cancels the transfer with CAN characters
  1483.  
  1484.     as described above.
  1485.  
  1486.  
  1487.     The receiver then initiates transfer of the file contents according to the
  1488.  
  1489.     standard XMODEM/CRC protocol.
  1490.  
  1491.  
  1492.     After the file contents have been transmitted, the receiver again asks for
  1493.  
  1494.     the next pathname.
  1495.  
  1496.  
  1497.     Transmission of a null pathname terminates batch file transmission.
  1498.  
  1499.  
  1500.     Note that transmission of no files is not necessarily an error.  This is
  1501.  
  1502.     possible if none of the files requested of the sender could be opened for
  1503.  
  1504.     reading.
  1505.  
  1506.  
  1507.  
  1508.  
  1509.     __________
  1510.  
  1511.  
  1512.      4. If, perchance, this information extends beyond 128 bytes (possible
  1513.  
  1514.         with Unix 4.2 BSD extended file names), the block should be sent as a
  1515.  
  1516.         1k block as described above.
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.     Chapter 5                                     XMODEM Protocol Enhancements
  1523.  
  1524.  
  1525.  
  1526.  
  1527.  
  1528.  
  1529.  
  1530.  
  1531.     X/YMODEM Protocol Reference      10-27-87                               15
  1532.  
  1533.  
  1534.  
  1535.  
  1536.     The YMODEM receiver requests CRC-16 by default.
  1537.  
  1538.  
  1539.     The Unix programs sz(1) and rz(1) included in the source code file
  1540.  
  1541.     RZSZ.ZOO should answer other questions about YMODEM batch protocol.
  1542.  
  1543.  
  1544.               Figure 3.  YMODEM Batch Transmission Session
  1545.  
  1546.  
  1547.               SENDER                                  RECEIVER
  1548.  
  1549.                                                       "sb foo.*<CR>"
  1550.  
  1551.               "sending in batch mode etc."
  1552.  
  1553.                                                       C (command:rb)
  1554.  
  1555.               SOH 00 FF foo.c NUL[123] CRC CRC
  1556.  
  1557.                                                       ACK
  1558.  
  1559.                                                       C
  1560.  
  1561.               SOH 01 FE Data[128] CRC CRC
  1562.  
  1563.                                                       ACK
  1564.  
  1565.               SOH 03 FC Data[128] CRC CRC
  1566.  
  1567.                                                       ACK
  1568.  
  1569.               SOH 04 FB Data[100] CPMEOF[28] CRC CRC
  1570.  
  1571.                                                       ACK
  1572.  
  1573.               EOT
  1574.  
  1575.                                                       NAK
  1576.  
  1577.               EOT
  1578.  
  1579.                                                       ACK
  1580.  
  1581.                                                       C
  1582.  
  1583.               SOH 00 FF NUL[128] CRC CRC
  1584.  
  1585.                                                       ACK
  1586.  
  1587.  
  1588.             Figure 4.  YMODEM Batch Transmission Session-1k Blocks
  1589.  
  1590.  
  1591.             SENDER                                  RECEIVER
  1592.  
  1593.                                                     "sb -k foo.*<CR>"
  1594.  
  1595.             "sending in batch mode etc."
  1596.  
  1597.                                                     C (command:rb)
  1598.  
  1599.             SOH 00 FF foo.c NUL[123] CRC CRC
  1600.  
  1601.                                                     ACK
  1602.  
  1603.                                                     C
  1604.  
  1605.             STX 02 FD Data[1024] CRC CRC
  1606.  
  1607.                                                     ACK
  1608.  
  1609.             SOH 03 FC Data[128] CRC CRC
  1610.  
  1611.                                                     ACK
  1612.  
  1613.             SOH 04 FB Data[100] CPMEOF[28] CRC CRC
  1614.  
  1615.                                                     ACK
  1616.  
  1617.             EOT
  1618.  
  1619.                                                     NAK
  1620.  
  1621.             EOT
  1622.  
  1623.                                                     ACK
  1624.  
  1625.                                                     C
  1626.  
  1627.             SOH 00 FF NUL[128] CRC CRC
  1628.  
  1629.                                                     ACK
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.     Chapter 5                                     XMODEM Protocol Enhancements
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.     X/YMODEM Protocol Reference      10-27-87                               16
  1645.  
  1646.  
  1647.  
  1648.  
  1649.            Figure 5.  YMODEM Filename block transmitted by sz
  1650.  
  1651.  
  1652.            -rw-r—r—6347 Jun 17 1984 20:34 bbcsched.txt
  1653.  
  1654.  
  1655.            00 0100FF62 62637363 6865642E 74787400   |…bbcsched.txt.|
  1656.  
  1657.            10 36333437 20333331 34373432 35313320   |6347 3314742513 |
  1658.  
  1659.            20 31303036 34340000 00000000 00000000   |100644……….|
  1660.  
  1661.            30 00000000 00000000 00000000 00000000
  1662.  
  1663.            40 00000000 00000000 00000000 00000000
  1664.  
  1665.            50 00000000 00000000 00000000 00000000
  1666.  
  1667.            60 00000000 00000000 00000000 00000000
  1668.  
  1669.            70 00000000 00000000 00000000 00000000
  1670.  
  1671.            80 000000CA 56
  1672.  
  1673.  
  1674.                 Figure 6.  YMODEM Header Information and Features
  1675.  
  1676.  
  1677.     _____________________________________________________________
  1678.  
  1679.     | Program   | Length | Date | Mode | S/N | 1k-Blk | YMODEM-g |
  1680.  
  1681.     |___________|________|______|______|_____|________|__________|
  1682.  
  1683.     |Unix rz/sz | yes    | yes  | yes  | no  | yes    | sb only  |
  1684.  
  1685.     |___________|________|______|______|_____|________|__________|
  1686.  
  1687.     |VMS rb/sb  | yes    | no   | no   | no  | yes    | no       |
  1688.  
  1689.     |___________|________|______|______|_____|________|__________|
  1690.  
  1691.     |Pro-YAM    | yes    | yes  | no   | yes | yes    | yes      |
  1692.  
  1693.     |___________|________|______|______|_____|________|__________|
  1694.  
  1695.     |CP/M YAM   | no     | no   | no   | no  | yes    | no       |
  1696.  
  1697.     |___________|________|______|______|_____|________|__________|
  1698.  
  1699.     |KMD/IMP    | ?      | no   | no   | no  | yes    | no       |
  1700.  
  1701.     |___________|________|______|______|_____|________|__________|
  1702.  
  1703.  
  1704.     5.1  KMD/IMP Exceptions to YMODEM
  1705.  
  1706.  
  1707.     KMD and IMP use a "CK" character sequence emitted by the receiver to
  1708.  
  1709.     trigger the use of 1024 byte blocks as an alternative to specifying this
  1710.  
  1711.     option to the sending program.  Although this two character sequence works
  1712.  
  1713.     well on single process micros in direct communication, timesharing systems
  1714.  
  1715.     and packet switched networks can separate the successive characters by
  1716.  
  1717.     several seconds, rendering this method unreliable.
  1718.  
  1719.  
  1720.     Sending programs may detect the CK sequence if the operating enviornment
  1721.  
  1722.     does not preclude reliable implementation.
  1723.  
  1724.  
  1725.     Instead of the standard YMODEM file length, KMD and IMP transmit the CP/M
  1726.  
  1727.     record count in the last two bytes of the header block.
  1728.  
  1729.  
  1730.  
  1731.  
  1732.  
  1733.  
  1734.  
  1735.  
  1736.  
  1737.  
  1738.  
  1739.     Chapter 6                                     XMODEM Protocol Enhancements
  1740.  
  1741.  
  1742.  
  1743.  
  1744.  
  1745.  
  1746.  
  1747.  
  1748.     X/YMODEM Protocol Reference      10-27-87                               17
  1749.  
  1750.  
  1751.  
  1752.  
  1753.     6.  YMODEM-g File Transmission
  1754.  
  1755.  
  1756.     Developing technology is providing phone line data transmission at ever
  1757.  
  1758.     higher speeds using very specialized techniques.  These high speed modems,
  1759.  
  1760.     as well as session protocols such as X.PC, provide high speed, nearly
  1761.  
  1762.     error free communications at the expense of considerably increased delay
  1763.  
  1764.     time.
  1765.  
  1766.  
  1767.     This delay time is moderate compared to human interactions, but it
  1768.  
  1769.     cripples the throughput of most error correcting protocols.
  1770.  
  1771.  
  1772.     The g option to YMODEM has proven effective under these circumstances.
  1773.  
  1774.     The g option is driven by the receiver, which initiates the batch transfer
  1775.  
  1776.     by transmitting a G instead of C.  When the sender recognizes the G, it
  1777.  
  1778.     bypasses the usual wait for an ACK to each transmitted block, sending
  1779.  
  1780.     succeeding blocks at full speed, subject to XOFF/XON or other flow control
  1781.  
  1782.     exerted by the medium.
  1783.  
  1784.  
  1785.     The sender expects an inital G to initiate the transmission of a
  1786.  
  1787.     particular file, and also expects an ACK on the EOT sent at the end of
  1788.  
  1789.     each file.  This synchronization allows the receiver time to open and
  1790.  
  1791.     close files as necessary.
  1792.  
  1793.  
  1794.     If an error is detected in a YMODEM-g transfer, the receiver aborts the
  1795.  
  1796.     transfer with the multiple CAN abort sequence.  The ZMODEM protocol should
  1797.  
  1798.     be used in applications that require both streaming throughput and error
  1799.  
  1800.     recovery.
  1801.  
  1802.  
  1803.             Figure 7.  YMODEM-g Transmission Session
  1804.  
  1805.  
  1806.             SENDER                                  RECEIVER
  1807.  
  1808.                                                     "sb foo.*<CR>"
  1809.  
  1810.             "sending in batch mode etc…"
  1811.  
  1812.                                                     G (command:rb -g)
  1813.  
  1814.             SOH 00 FF foo.c NUL[123] CRC CRC
  1815.  
  1816.                                                     G
  1817.  
  1818.             SOH 01 FE Data[128] CRC CRC
  1819.  
  1820.             STX 02 FD Data[1024] CRC CRC
  1821.  
  1822.             SOH 03 FC Data[128] CRC CRC
  1823.  
  1824.             SOH 04 FB Data[100] CPMEOF[28] CRC CRC
  1825.  
  1826.             EOT
  1827.  
  1828.                                                     ACK
  1829.  
  1830.                                                     G
  1831.  
  1832.             SOH 00 FF NUL[128] CRC CRC
  1833.  
  1834.  
  1835.  
  1836.  
  1837.  
  1838.  
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.     Chapter 6                                     XMODEM Protocol Enhancements
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.  
  1853.     X/YMODEM Protocol Reference      10-27-87                               18
  1854.  
  1855.  
  1856.  
  1857.  
  1858.     7.  XMODEM PROTOCOL OVERVIEW
  1859.  
  1860.  
  1861.     8/9/82 by Ward Christensen.
  1862.  
  1863.  
  1864.     I will maintain a master copy of this.  Please pass on changes or
  1865.  
  1866.     suggestions via CBBS/Chicago at (312) 545-8086, CBBS/CPMUG (312) 849-1132
  1867.  
  1868.     or by voice at (312) 849-6279.
  1869.  
  1870.  
  1871.     7.1  Definitions
  1872.  
  1873.  
  1874.       <soh> 01H
  1875.  
  1876.       <eot> 04H
  1877.  
  1878.       <ack> 06H
  1879.  
  1880.       <nak> 15H
  1881.  
  1882.       <can> 18H
  1883.  
  1884.       <C>   43H
  1885.  
  1886.  
  1887.  
  1888.     7.2  Transmission Medium Level Protocol
  1889.  
  1890.  
  1891.     Asynchronous, 8 data bits, no parity, one stop bit.
  1892.  
  1893.  
  1894.     The protocol imposes no restrictions on the contents of the data being
  1895.  
  1896.     transmitted.  No control characters are looked for in the 128-byte data
  1897.  
  1898.     messages.  Absolutely any kind of data may be sent - binary, ASCII, etc.
  1899.  
  1900.     The protocol has not formally been adopted to a 7-bit environment for the
  1901.  
  1902.     transmission of ASCII-only (or unpacked-hex) data , although it could be
  1903.  
  1904.     simply by having both ends agree to AND the protocol-dependent data with
  1905.  
  1906.     7F hex before validating it.  I specifically am referring to the checksum,
  1907.  
  1908.     and the block numbers and their ones- complement.
  1909.  
  1910.  
  1911.     Those wishing to maintain compatibility of the CP/M file structure, i.e.
  1912.  
  1913.     to allow modemming ASCII files to or from CP/M systems should follow this
  1914.  
  1915.     data format:
  1916.  
  1917.  
  1918.        + ASCII tabs used (09H); tabs set every 8.
  1919.  
  1920.  
  1921.        + Lines terminated by CR/LF (0DH 0AH)
  1922.  
  1923.  
  1924.        + End-of-file indicated by ^Z, 1AH.  (one or more)
  1925.  
  1926.  
  1927.        + Data is variable length, i.e. should be considered a continuous
  1928.  
  1929.          stream of data bytes, broken into 128-byte chunks purely for the
  1930.  
  1931.          purpose of transmission.
  1932.  
  1933.  
  1934.        + A CP/M "peculiarity": If the data ends exactly on a 128-byte
  1935.  
  1936.          boundary, i.e. CR in 127, and LF in 128, a subsequent sector
  1937.  
  1938.          containing the ^Z EOF character(s) is optional, but is preferred.
  1939.  
  1940.          Some utilities or user programs still do not handle EOF without ^Zs.
  1941.  
  1942.  
  1943.  
  1944.  
  1945.  
  1946.  
  1947.     Chapter 7                                         Xmodem Protocol Overview
  1948.  
  1949.  
  1950.  
  1951.  
  1952.  
  1953.  
  1954.  
  1955.  
  1956.     X/YMODEM Protocol Reference      10-27-87                               19
  1957.  
  1958.  
  1959.  
  1960.  
  1961.        + The last block sent is no different from others, i.e.  there is no
  1962.  
  1963.          "short block".
  1964.  
  1965.                   Figure 8.  XMODEM Message Block Level Protocol
  1966.  
  1967.  
  1968.     Each block of the transfer looks like:
  1969.  
  1970.           <SOH><blk #><255-blk #><—128 data bytes—><cksum>
  1971.  
  1972.     in which:
  1973.  
  1974.     <SOH>         = 01 hex
  1975.  
  1976.     <blk #>       = binary number, starts at 01 increments by 1, and
  1977.  
  1978.                     wraps 0FFH to 00H (not to 01)
  1979.  
  1980.     <255-blk #>   = blk # after going thru 8080 "CMA" instr, i.e.
  1981.  
  1982.                     each bit complemented in the 8-bit block number.
  1983.  
  1984.                     Formally, this is the "ones complement".
  1985.  
  1986.     <cksum>       = the sum of the data bytes only.  Toss any carry.
  1987.  
  1988.  
  1989.     7.3  File Level Protocol
  1990.  
  1991.  
  1992.     7.3.1  Common_to_Both_Sender_and_Receiver
  1993.  
  1994.     All errors are retried 10 times.  For versions running with an operator
  1995.  
  1996.     (i.e. NOT with XMODEM), a message is typed after 10 errors asking the
  1997.  
  1998.     operator whether to "retry or quit".
  1999.  
  2000.  
  2001.     Some versions of the protocol use <can>, ASCII ^X, to cancel transmission.
  2002.  
  2003.     This was never adopted as a standard, as having a single "abort" character
  2004.  
  2005.     makes the transmission susceptible to false termination due to an <ack>
  2006.  
  2007.     <nak> or <soh> being corrupted into a <can> and aborting transmission.
  2008.  
  2009.  
  2010.     The protocol may be considered "receiver driven", that is, the sender need
  2011.  
  2012.     not automatically re-transmit, although it does in the current
  2013.  
  2014.     implementations.
  2015.  
  2016.  
  2017.  
  2018.     7.3.2  Receive_Program_Considerations
  2019.  
  2020.     The receiver has a 10-second timeout.  It sends a <nak> every time it
  2021.  
  2022.     times out.  The receiver's first timeout, which sends a <nak>, signals the
  2023.  
  2024.     transmitter to start.  Optionally, the receiver could send a <nak>
  2025.  
  2026.     immediately, in case the sender was ready.  This would save the initial 10
  2027.  
  2028.     second timeout.  However, the receiver MUST continue to timeout every 10
  2029.  
  2030.     seconds in case the sender wasn't ready.
  2031.  
  2032.  
  2033.     Once into a receiving a block, the receiver goes into a one-second timeout
  2034.  
  2035.     for each character and the checksum.  If the receiver wishes to <nak> a
  2036.  
  2037.     block for any reason (invalid header, timeout receiving data), it must
  2038.  
  2039.     wait for the line to clear.  See "programming tips" for ideas
  2040.  
  2041.  
  2042.     Synchronizing:  If a valid block number is received, it will be: 1) the
  2043.  
  2044.     expected one, in which case everything is fine; or 2) a repeat of the
  2045.  
  2046.     previously received block.  This should be considered OK, and only
  2047.  
  2048.     indicates that the receivers <ack> got glitched, and the sender re-
  2049.  
  2050.     transmitted; 3) any other block number indicates a fatal loss of
  2051.  
  2052.     synchronization, such as the rare case of the sender getting a line-glitch
  2053.  
  2054.  
  2055.  
  2056.  
  2057.     Chapter 7                                         Xmodem Protocol Overview
  2058.  
  2059.  
  2060.  
  2061.  
  2062.  
  2063.  
  2064.  
  2065.  
  2066.     X/YMODEM Protocol Reference      10-27-87                               20
  2067.  
  2068.  
  2069.  
  2070.  
  2071.     that looked like an <ack>.  Abort the transmission, sending a <can>
  2072.  
  2073.  
  2074.  
  2075.     7.3.3  Sending_program_considerations
  2076.  
  2077.     While waiting for transmission to begin, the sender has only a single very
  2078.  
  2079.     long timeout, say one minute.  In the current protocol, the sender has a
  2080.  
  2081.     10 second timeout before retrying.  I suggest NOT doing this, and letting
  2082.  
  2083.     the protocol be completely receiver-driven.  This will be compatible with
  2084.  
  2085.     existing programs.
  2086.  
  2087.  
  2088.     When the sender has no more data, it sends an <eot>, and awaits an <ack>,
  2089.  
  2090.     resending the <eot> if it doesn't get one.  Again, the protocol could be
  2091.  
  2092.     receiver-driven, with the sender only having the high-level 1-minute
  2093.  
  2094.     timeout to abort.
  2095.  
  2096.  
  2097.  
  2098.     Here is a sample of the data flow, sending a 3-block message.  It includes
  2099.  
  2100.     the two most common line hits - a garbaged block, and an <ack> reply
  2101.  
  2102.     getting garbaged.  <xx> represents the checksum byte.
  2103.  
  2104.  
  2105.                   Figure 9.  Data flow including Error Recovery
  2106.  
  2107.  
  2108.     SENDER                                  RECEIVER
  2109.  
  2110.                                   times out after 10 seconds,
  2111.  
  2112.                                   <—-              <nak>
  2113.  
  2114.     <soh> 01 FE -data- <xx>—->
  2115.  
  2116.                                   <—-              <ack>
  2117.  
  2118.     <soh> 02 FD -data- xx—->       (data gets line hit)
  2119.  
  2120.                                   <—-              <nak>
  2121.  
  2122.     <soh> 02 FD -data- xx—->
  2123.  
  2124.                                   <—-              <ack>
  2125.  
  2126.     <soh> 03 FC -data- xx—->
  2127.  
  2128.     (ack gets garbaged)           <—-              <ack>
  2129.  
  2130.     <soh> 03 FC -data- xx—->              <ack>
  2131.  
  2132.     <eot>—->
  2133.  
  2134.                                   <—-       <anything except ack>
  2135.  
  2136.     <eot>—->
  2137.  
  2138.                                   <—-              <ack>
  2139.  
  2140.     (finished)
  2141.  
  2142.  
  2143.     7.4  Programming Tips
  2144.  
  2145.  
  2146.        + The character-receive subroutine should be called with a parameter
  2147.  
  2148.          specifying the number of seconds to wait.  The receiver should first
  2149.  
  2150.          call it with a time of 10, then <nak> and try again, 10 times.
  2151.  
  2152.  
  2153.          After receiving the <soh>, the receiver should call the character
  2154.  
  2155.          receive subroutine with a 1-second timeout, for the remainder of the
  2156.  
  2157.          message and the <cksum>.  Since they are sent as a continuous stream,
  2158.  
  2159.          timing out of this implies a serious like glitch that caused, say,
  2160.  
  2161.          127 characters to be seen instead of 128.
  2162.  
  2163.  
  2164.  
  2165.  
  2166.     Chapter 7                                         Xmodem Protocol Overview
  2167.  
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.     X/YMODEM Protocol Reference      10-27-87                               21
  2176.  
  2177.  
  2178.  
  2179.  
  2180.        + When the receiver wishes to <nak>, it should call a "PURGE"
  2181.  
  2182.          subroutine, to wait for the line to clear.  Recall the sender tosses
  2183.  
  2184.          any characters in its UART buffer immediately upon completing sending
  2185.  
  2186.          a block, to ensure no glitches were mis- interpreted.
  2187.  
  2188.  
  2189.          The most common technique is for "PURGE" to call the character
  2190.  
  2191.          receive subroutine, specifying a 1-second timeout,[1] and looping
  2192.  
  2193.          back to PURGE until a timeout occurs.  The <nak> is then sent,
  2194.  
  2195.          ensuring the other end will see it.
  2196.  
  2197.  
  2198.        + You may wish to add code recommended by John Mahr to your character
  2199.  
  2200.          receive routine - to set an error flag if the UART shows framing
  2201.  
  2202.          error, or overrun.  This will help catch a few more glitches - the
  2203.  
  2204.          most common of which is a hit in the high bits of the byte in two
  2205.  
  2206.          consecutive bytes.  The <cksum> comes out OK since counting in 1-byte
  2207.  
  2208.          produces the same result of adding 80H + 80H as with adding 00H +
  2209.  
  2210.          00H.
  2211.  
  2212.  
  2213.  
  2214.  
  2215.  
  2216.  
  2217.  
  2218.  
  2219.  
  2220.  
  2221.  
  2222.  
  2223.  
  2224.  
  2225.  
  2226.  
  2227.  
  2228.  
  2229.  
  2230.  
  2231.  
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242.     __________
  2243.  
  2244.  
  2245.      1. These times should be adjusted for use with timesharing systems.
  2246.  
  2247.  
  2248.  
  2249.  
  2250.  
  2251.     Chapter 7                                         Xmodem Protocol Overview
  2252.  
  2253.  
  2254.  
  2255.  
  2256.  
  2257.  
  2258.  
  2259.  
  2260.     X/YMODEM Protocol Reference      10-27-87                               22
  2261.  
  2262.  
  2263.  
  2264.  
  2265.     8.  XMODEM/CRC Overview
  2266.  
  2267.  
  2268.     Original 1/13/85 by John Byrns—CRC option.
  2269.  
  2270.  
  2271.     Please pass on any reports of errors in this document or suggestions for
  2272.  
  2273.     improvement to me via Ward's/CBBS at (312) 849-1132, or by voice at (312)
  2274.  
  2275.     885-1105.
  2276.  
  2277.  
  2278.     The CRC used in the Modem Protocol is an alternate form of block check
  2279.  
  2280.     which provides more robust error detection than the original checksum.
  2281.  
  2282.     Andrew S. Tanenbaum says in his book, Computer Networks, that the CRC-
  2283.  
  2284.     CCITT used by the Modem Protocol will detect all single and double bit
  2285.  
  2286.     errors, all errors with an odd number of bits, all burst errors of length
  2287.  
  2288.     16 or less, 99.997% of 17-bit error bursts, and 99.998% of 18-bit and
  2289.  
  2290.     longer bursts.[1]
  2291.  
  2292.  
  2293.     The changes to the Modem Protocol to replace the checksum with the CRC are
  2294.  
  2295.     straight forward. If that were all that we did we would not be able to
  2296.  
  2297.     communicate between a program using the old checksum protocol and one
  2298.  
  2299.     using the new CRC protocol. An initial handshake was added to solve this
  2300.  
  2301.     problem. The handshake allows a receiving program with CRC capability to
  2302.  
  2303.     determine whether the sending program supports the CRC option, and to
  2304.  
  2305.     switch it to CRC mode if it does. This handshake is designed so that it
  2306.  
  2307.     will work properly with programs which implement only the original
  2308.  
  2309.     protocol. A description of this handshake is presented in section 10.
  2310.  
  2311.  
  2312.                 Figure 10.  Message Block Level Protocol, CRC mode
  2313.  
  2314.  
  2315.     Each block of the transfer in CRC mode looks like:
  2316.  
  2317.          <SOH><blk #><255-blk #><—128 data bytes—><CRC hi><CRC lo>
  2318.  
  2319.     in which:
  2320.  
  2321.     <SOH>        = 01 hex
  2322.  
  2323.     <blk #>      = binary number, starts at 01 increments by 1, and
  2324.  
  2325.                    wraps 0FFH to 00H (not to 01)
  2326.  
  2327.     <255-blk #>  = ones complement of blk #.
  2328.  
  2329.     <CRC hi>     = byte containing the 8 hi order coefficients of the CRC.
  2330.  
  2331.     <CRC lo>     = byte containing the 8 lo order coefficients of the CRC.
  2332.  
  2333.  
  2334.     8.1  CRC Calculation
  2335.  
  2336.  
  2337.     8.1.1  Formal_Definition
  2338.  
  2339.     To calculate the 16 bit CRC the message bits are considered to be the
  2340.  
  2341.     coefficients of a polynomial. This message polynomial is first multiplied
  2342.  
  2343.     by X^16 and then divided by the generator polynomial (X^16 + X^12 + X^5 +
  2344.  
  2345.  
  2346.  
  2347.     __________
  2348.  
  2349.  
  2350.      1. This reliability figure is misleading because XMODEM's critical
  2351.  
  2352.         supervisory functions are not protected by this CRC.
  2353.  
  2354.  
  2355.  
  2356.  
  2357.  
  2358.     Chapter 8                                         Xmodem Protocol Overview
  2359.  
  2360.  
  2361.  
  2362.  
  2363.  
  2364.  
  2365.  
  2366.  
  2367.     X/YMODEM Protocol Reference      10-27-87                               23
  2368.  
  2369.  
  2370.  
  2371.  
  2372.     1) using modulo two arithmetic. The remainder left after the division is
  2373.  
  2374.     the desired CRC. Since a message block in the Modem Protocol is 128 bytes
  2375.  
  2376.     or 1024 bits, the message polynomial will be of order X^1023. The hi order
  2377.  
  2378.     bit of the first byte of the message block is the coefficient of X^1023 in
  2379.  
  2380.     the message polynomial.  The lo order bit of the last byte of the message
  2381.  
  2382.     block is the coefficient of X^0 in the message polynomial.
  2383.  
  2384.  
  2385.                Figure 11.  Example of CRC Calculation written in C
  2386.  
  2387.  
  2388.     The following XMODEM crc routine is taken from "rbsb.c".  Please refer to
  2389.  
  2390.     the source code for these programs (contained in RZSZ.ZOO) for usage.  A
  2391.  
  2392.     fast table driven version is also included in this file.
  2393.  
  2394.  
  2395.     /* update CRC */
  2396.  
  2397.     unsigned short
  2398.  
  2399.     updcrc(c, crc)
  2400.  
  2401.     register c;
  2402.  
  2403.     register unsigned crc;
  2404.  
  2405.     {
  2406.  
  2407.             register count;
  2408.  
  2409.  
  2410.             for (count=8;—count>=0;) {
  2411.  
  2412.                     if (crc & 0x8000) {
  2413.  
  2414.                             crc <<= 1;
  2415.  
  2416.                             crc += (((c<<=1) & 0400)  !=  0);
  2417.  
  2418.                             crc ^= 0x1021;
  2419.  
  2420.                     }
  2421.  
  2422.                     else {
  2423.  
  2424.                             crc <<= 1;
  2425.  
  2426.                             crc += (((c<<=1) & 0400)  !=  0);
  2427.  
  2428.                     }
  2429.  
  2430.             }
  2431.  
  2432.             return crc;
  2433.  
  2434.     }
  2435.  
  2436.  
  2437.     8.2  CRC File Level Protocol Changes
  2438.  
  2439.  
  2440.     8.2.1  Common_to_Both_Sender_and_Receiver
  2441.  
  2442.     The only change to the File Level Protocol for the CRC option is the
  2443.  
  2444.     initial handshake which is used to determine if both the sending and the
  2445.  
  2446.     receiving programs support the CRC mode. All Modem Programs should support
  2447.  
  2448.     the checksum mode for compatibility with older versions.  A receiving
  2449.  
  2450.     program that wishes to receive in CRC mode implements the mode setting
  2451.  
  2452.     handshake by sending a <C> in place of the initial <nak>.  If the sending
  2453.  
  2454.     program supports CRC mode it will recognize the <C> and will set itself
  2455.  
  2456.     into CRC mode, and respond by sending the first block as if a <nak> had
  2457.  
  2458.     been received. If the sending program does not support CRC mode it will
  2459.  
  2460.     not respond to the <C> at all. After the receiver has sent the <C> it will
  2461.  
  2462.     wait up to 3 seconds for the <soh> that starts the first block. If it
  2463.  
  2464.     receives a <soh> within 3 seconds it will assume the sender supports CRC
  2465.  
  2466.     mode and will proceed with the file exchange in CRC mode. If no <soh> is
  2467.  
  2468.  
  2469.  
  2470.  
  2471.     Chapter 8                                         Xmodem Protocol Overview
  2472.  
  2473.  
  2474.  
  2475.  
  2476.  
  2477.  
  2478.  
  2479.  
  2480.     X/YMODEM Protocol Reference      10-27-87                               24
  2481.  
  2482.  
  2483.  
  2484.  
  2485.     received within 3 seconds the receiver will switch to checksum mode, send
  2486.  
  2487.     a <nak>, and proceed in checksum mode. If the receiver wishes to use
  2488.  
  2489.     checksum mode it should send an initial <nak> and the sending program
  2490.  
  2491.     should respond to the <nak> as defined in the original Modem Protocol.
  2492.  
  2493.     After the mode has been set by the initial <C> or <nak> the protocol
  2494.  
  2495.     follows the original Modem Protocol and is identical whether the checksum
  2496.  
  2497.     or CRC is being used.
  2498.  
  2499.  
  2500.  
  2501.     8.2.2  Receive_Program_Considerations
  2502.  
  2503.     There are at least 4 things that can go wrong with the mode setting
  2504.  
  2505.     handshake.
  2506.  
  2507.  
  2508.       1.  the initial <C> can be garbled or lost.
  2509.  
  2510.  
  2511.       2.  the initial <soh> can be garbled.
  2512.  
  2513.  
  2514.       3.  the initial <C> can be changed to a <nak>.
  2515.  
  2516.  
  2517.       4.  the initial <nak> from a receiver which wants to receive in checksum
  2518.  
  2519.           can be changed to a <C>.
  2520.  
  2521.  
  2522.     The first problem can be solved if the receiver sends a second <C> after
  2523.  
  2524.     it times out the first time. This process can be repeated several times.
  2525.  
  2526.     It must not be repeated too many times before sending a <nak> and
  2527.  
  2528.     switching to checksum mode or a sending program without CRC support may
  2529.  
  2530.     time out and abort. Repeating the <C> will also fix the second problem if
  2531.  
  2532.     the sending program cooperates by responding as if a <nak> were received
  2533.  
  2534.     instead of ignoring the extra <C>.
  2535.  
  2536.  
  2537.     It is possible to fix problems 3 and 4 but probably not worth the trouble
  2538.  
  2539.     since they will occur very infrequently. They could be fixed by switching
  2540.  
  2541.     modes in either the sending or the receiving program after a large number
  2542.  
  2543.     of successive <nak>s. This solution would risk other problems however.
  2544.  
  2545.  
  2546.  
  2547.     8.2.3  Sending_Program_Considerations
  2548.  
  2549.     The sending program should start in the checksum mode. This will insure
  2550.  
  2551.     compatibility with checksum only receiving programs. Anytime a <C> is
  2552.  
  2553.     received before the first <nak> or <ack> the sending program should set
  2554.  
  2555.     itself into CRC mode and respond as if a <nak> were received. The sender
  2556.  
  2557.     should respond to additional <C>s as if they were <nak>s until the first
  2558.  
  2559.     <ack> is received. This will assist the receiving program in determining
  2560.  
  2561.     the correct mode when the <soh> is lost or garbled. After the first <ack>
  2562.  
  2563.     is received the sending program should ignore <C>s.
  2564.  
  2565.  
  2566.  
  2567.  
  2568.  
  2569.  
  2570.  
  2571.  
  2572.  
  2573.  
  2574.     Chapter 8                                         Xmodem Protocol Overview
  2575.  
  2576.  
  2577.  
  2578.  
  2579.  
  2580.  
  2581.  
  2582.  
  2583.     X/YMODEM Protocol Reference      10-27-87                               25
  2584.  
  2585.  
  2586.  
  2587.  
  2588.     8.3  Data Flow Examples with CRC Option
  2589.  
  2590.  
  2591.     Here is a data flow example for the case where the receiver requests
  2592.  
  2593.     transmission in the CRC mode but the sender does not support the CRC
  2594.  
  2595.     option. This example also includes various transmission errors.  <xx>
  2596.  
  2597.     represents the checksum byte.
  2598.  
  2599.  
  2600.           Figure 12.  Data Flow: Receiver has CRC Option, Sender Doesn't
  2601.  
  2602.  
  2603.     SENDER                                        RECEIVER
  2604.  
  2605.                             <—-                <C>
  2606.  
  2607.                                     times out after 3 seconds,
  2608.  
  2609.                             <—-                <C>
  2610.  
  2611.                                     times out after 3 seconds,
  2612.  
  2613.                             <—-                <C>
  2614.  
  2615.                                     times out after 3 seconds,
  2616.  
  2617.                             <—-                <C>
  2618.  
  2619.                                     times out after 3 seconds,
  2620.  
  2621.                             <—-                <nak>
  2622.  
  2623.     <soh> 01 FE -data- <xx>—->
  2624.  
  2625.                             <—-                <ack>
  2626.  
  2627.     <soh> 02 FD -data- <xx>—->        (data gets line hit)
  2628.  
  2629.                             <—-                <nak>
  2630.  
  2631.     <soh> 02 FD -data- <xx>—->
  2632.  
  2633.                             <—-                <ack>
  2634.  
  2635.     <soh> 03 FC -data- <xx>—->
  2636.  
  2637.        (ack gets garbaged)  <—-                <ack>
  2638.  
  2639.                                     times out after 10 seconds,
  2640.  
  2641.                             <—-                <nak>
  2642.  
  2643.     <soh> 03 FC -data- <xx>—->
  2644.  
  2645.                             <—-                <ack>
  2646.  
  2647.     <eot>—->
  2648.  
  2649.                             <—-                <ack>
  2650.  
  2651.  
  2652.     Here is a data flow example for the case where the receiver requests
  2653.  
  2654.     transmission in the CRC mode and the sender supports the CRC option.  This
  2655.  
  2656.     example also includes various transmission errors.  <xxxx> represents the
  2657.  
  2658.     2 CRC bytes.
  2659.  
  2660.  
  2661.  
  2662.  
  2663.  
  2664.  
  2665.  
  2666.  
  2667.  
  2668.  
  2669.  
  2670.  
  2671.  
  2672.  
  2673.  
  2674.  
  2675.  
  2676.     Chapter 8                                         Xmodem Protocol Overview
  2677.  
  2678.  
  2679.  
  2680.  
  2681.  
  2682.  
  2683.  
  2684.  
  2685.     X/YMODEM Protocol Reference      10-27-87                               26
  2686.  
  2687.  
  2688.  
  2689.  
  2690.                Figure 13.  Receiver and Sender Both have CRC Option
  2691.  
  2692.  
  2693.     SENDER                                       RECEIVER
  2694.  
  2695.                               <—-                 <C>
  2696.  
  2697.     <soh> 01 FE -data- <xxxx>—->
  2698.  
  2699.                               <—-                 <ack>
  2700.  
  2701.     <soh> 02 FD -data- <xxxx>—->         (data gets line hit)
  2702.  
  2703.                               <—-                 <nak>
  2704.  
  2705.     <soh> 02 FD -data- <xxxx>—->
  2706.  
  2707.                               <—-                 <ack>
  2708.  
  2709.     <soh> 03 FC -data- <xxxx>—->
  2710.  
  2711.     (ack gets garbaged)       <—-                 <ack>
  2712.  
  2713.                                          times out after 10 seconds,
  2714.  
  2715.                               <—-                 <nak>
  2716.  
  2717.     <soh> 03 FC -data- <xxxx>—->
  2718.  
  2719.                               <—-                 <ack>
  2720.  
  2721.     <eot>—->
  2722.  
  2723.                               <—-                 <ack>
  2724.  
  2725.  
  2726.  
  2727.  
  2728.  
  2729.  
  2730.  
  2731.  
  2732.  
  2733.  
  2734.  
  2735.  
  2736.  
  2737.  
  2738.  
  2739.  
  2740.  
  2741.  
  2742.  
  2743.  
  2744.  
  2745.  
  2746.  
  2747.  
  2748.  
  2749.  
  2750.  
  2751.  
  2752.  
  2753.  
  2754.  
  2755.  
  2756.  
  2757.  
  2758.  
  2759.  
  2760.  
  2761.     Chapter 8                                         Xmodem Protocol Overview
  2762.  
  2763.  
  2764.  
  2765.  
  2766.  
  2767.  
  2768.  
  2769.  
  2770.     X/YMODEM Protocol Reference      10-27-87                               27
  2771.  
  2772.  
  2773.  
  2774.  
  2775.     9.  MORE INFORMATION
  2776.  
  2777.  
  2778.     Please contact Omen Technology for troff source files and typeset copies
  2779.  
  2780.     of this document.
  2781.  
  2782.  
  2783.  
  2784.     9.1  TeleGodzilla Bulletin Board
  2785.  
  2786.  
  2787.     More information may be obtained by calling TeleGodzilla at 503-621-3746.
  2788.  
  2789.     Speed detection is automatic for 1200, 2400 and 19200(Telebit PEP) bps.
  2790.  
  2791.     TrailBlazer modem users may issue the TeleGodzilla trailblazer command to
  2792.  
  2793.     swith to 19200 bps once they have logged in.
  2794.  
  2795.  
  2796.     Interesting files include RZSZ.ZOO (C source code), YZMODEM.ZOO (Official
  2797.  
  2798.     XMODEM, YMODEM, and ZMODEM protocol descriptions), ZCOMMEXE.ARC,
  2799.  
  2800.     ZCOMMDOC.ARC, and ZCOMMHLP.ARC (PC-DOS shareware comm program with XMODEM,
  2801.  
  2802.     True YMODEM(TM), ZMODEM, Kermit Sliding Windows, Telink, MODEM7 Batch,
  2803.  
  2804.     script language, etc.).
  2805.  
  2806.  
  2807.  
  2808.     9.2  Unix UUCP Access
  2809.  
  2810.  
  2811.     UUCP sites can obtain the current version of this file with
  2812.  
  2813.                      uucp omen!/u/caf/public/ymodem.doc /tmp
  2814.  
  2815.     A continually updated list of available files is stored in
  2816.  
  2817.     /usr/spool/uucppublic/FILES.  When retrieving these files with uucp,
  2818.  
  2819.     remember that the destination directory on your system must be writeable
  2820.  
  2821.     by anyone, or the UUCP transfer will fail.
  2822.  
  2823.  
  2824.     The following L.sys line calls TeleGodzilla (Pro-YAM in host operation).
  2825.  
  2826.     TeleGodzilla determines the incoming speed automatically.
  2827.  
  2828.  
  2829.     In response to "Name Please:" uucico gives the Pro-YAM "link" command as a
  2830.  
  2831.     user name.  The password (Giznoid) controls access to the Xenix system
  2832.  
  2833.     connected to the IBM PC's other serial port.  Communications between
  2834.  
  2835.     Pro-YAM and Xenix use 9600 bps; YAM converts this to the caller's speed.
  2836.  
  2837.  
  2838.     Finally, the calling uucico logs in as uucp.
  2839.  
  2840.  
  2841.     omen Any ACU 2400 1-503-621-3746 se:—se: link ord: Giznoid in:—in: uucp
  2842.  
  2843.  
  2844.  
  2845.  
  2846.     10.  REVISIONS
  2847.  
  2848.  
  2849.     10-27-87 Optional fields added for number of files remaining to be sent
  2850.  
  2851.     and total number of bytes remaining to be sent.
  2852.  
  2853.     10-18-87 Flow control discussion added to 1024 byte block descritpion,
  2854.  
  2855.     minor revisions for clarity per user comments.
  2856.  
  2857.     8-03-87 Revised for clarity.
  2858.  
  2859.     5-31-1987 emphasizes minimum requirements for YMODEM, and updates
  2860.  
  2861.  
  2862.  
  2863.  
  2864.     Chapter 10                                        Xmodem Protocol Overview
  2865.  
  2866.  
  2867.  
  2868.  
  2869.  
  2870.  
  2871.  
  2872.  
  2873.     X/YMODEM Protocol Reference      10-27-87                               28
  2874.  
  2875.  
  2876.  
  2877.  
  2878.     information on accessing files.
  2879.  
  2880.     9-11-1986 clarifies nomenclature and some minor points.
  2881.  
  2882.     The April 15 1986 edition clarifies some points concerning CRC
  2883.  
  2884.     calculations and spaces in the header.
  2885.  
  2886.  
  2887.  
  2888.     11.  YMODEM Programs
  2889.  
  2890.  
  2891.     ZCOMM, A shareware little brother to Professional-YAM, is available as
  2892.  
  2893.     ZCOMMEXE.ARC on TeleGodzilla and other bulletin board systems.  ZCOMM may
  2894.  
  2895.     be used to test YMODEM amd ZMODEM implementations.
  2896.  
  2897.  
  2898.     Unix programs supporting YMODEM are available on TeleGodzilla in RZSZ.ZOO.
  2899.  
  2900.     This ZOO archive includes a ZCOMM/Pro-YAM/PowerCom script ZUPL.T to upload
  2901.  
  2902.     a bootstrap program MINIRB.C, compile it, and then upload the rest of the
  2903.  
  2904.     files using the compiled MINIRB.  Most Unix like systems are supported,
  2905.  
  2906.     including V7, Xenix, Sys III, 4.2 BSD, SYS V, Idris, Coherent, and
  2907.  
  2908.     Regulus.
  2909.  
  2910.  
  2911.     A version for VAX-VMS is available in VRBSB.SHQ.
  2912.  
  2913.  
  2914.     Irv Hoff has added 1k blocks and basic YMODEM batch transfers to the KMD
  2915.  
  2916.     and IMP series programs, which replace the XMODEM and MODEM7/MDM7xx series
  2917.  
  2918.     respectively.  Overlays are available for a wide variety of CP/M systems.
  2919.  
  2920.  
  2921.     Questions about Professional-YAM communications software may be directed
  2922.  
  2923.     to:
  2924.  
  2925.          Chuck Forsberg
  2926.  
  2927.          Omen Technology Inc
  2928.  
  2929.          17505-V Sauvie Island Road
  2930.  
  2931.          Portland Oregon 97231
  2932.  
  2933.          VOICE: 503-621-3406 :VOICE
  2934.  
  2935.          Modem: 503-621-3746 Speed: 19200(Telebit PEP),2400,1200,300
  2936.  
  2937.          Usenet: …!tektronix!reed!omen!caf
  2938.  
  2939.          CompuServe: 70007,2304
  2940.  
  2941.          GEnie: CAF
  2942.  
  2943.  
  2944.     Unlike ZMODEM and Kermit, XMODEM and YMODEM place obstacles in the path of
  2945.  
  2946.     a reliable high performance implementation, evidenced by poor reliability
  2947.  
  2948.     under stress of the industry leaders' XMODEM and YMODEM programs.  Omen
  2949.  
  2950.     Technology provides consulting and other services to those wishing to
  2951.  
  2952.     implement XMODEM, YMODEM, and ZMODEM with state of the art features and
  2953.  
  2954.     reliability.
  2955.  
  2956.  
  2957.  
  2958.  
  2959.  
  2960.  
  2961.  
  2962.  
  2963.  
  2964.  
  2965.  
  2966.  
  2967.     Chapter 11                                        Xmodem Protocol Overview
  2968.  
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974.  
  2975.  
  2976.  
  2977.  
  2978.  
  2979.  
  2980.                                      CONTENTS
  2981.  
  2982.  
  2983.  
  2984.      1.  TOWER OF BABEL……………………………………………   2
  2985.  
  2986.          1.1  Definitions………………………………………….   2
  2987.  
  2988.  
  2989.      2.  YMODEM MINIMUM REQUIREMENTS………………………………..   4
  2990.  
  2991.  
  2992.      3.  WHY YMODEM?………………………………………………   5
  2993.  
  2994.          3.1  Some Messages from the Pioneer…………………………   6
  2995.  
  2996.  
  2997.      4.  XMODEM PROTOCOL ENHANCEMENTS……………………………….   9
  2998.  
  2999.          4.1  Graceful Abort……………………………………….   9
  3000.  
  3001.          4.2  CRC-16 Option………………………………………..   9
  3002.  
  3003.          4.3  XMODEM-1k 1024 Byte Block……………………………..  10
  3004.  
  3005.  
  3006.      5.  YMODEM Batch File Transmission……………………………..  12
  3007.  
  3008.          5.1  KMD/IMP Exceptions to YMODEM…………………………..  16
  3009.  
  3010.  
  3011.      6.  YMODEM-g File Transmission…………………………………  17
  3012.  
  3013.  
  3014.      7.  XMODEM PROTOCOL OVERVIEW…………………………………..  18
  3015.  
  3016.          7.1  Definitions………………………………………….  18
  3017.  
  3018.          7.2  Transmission Medium Level Protocol……………………..  18
  3019.  
  3020.          7.3  File Level Protocol…………………………………..  19
  3021.  
  3022.          7.4  Programming Tips……………………………………..  20
  3023.  
  3024.  
  3025.      8.  XMODEM/CRC Overview……………………………………….  22
  3026.  
  3027.          8.1  CRC Calculation………………………………………  22
  3028.  
  3029.          8.2  CRC File Level Protocol Changes………………………..  23
  3030.  
  3031.          8.3  Data Flow Examples with CRC Option……………………..  25
  3032.  
  3033.  
  3034.      9.  MORE INFORMATION………………………………………….  27
  3035.  
  3036.          9.1  TeleGodzilla Bulletin Board……………………………  27
  3037.  
  3038.          9.2  Unix UUCP Access……………………………………..  27
  3039.  
  3040.  
  3041.     10.  REVISIONS………………………………………………..  27
  3042.  
  3043.  
  3044.     11.  YMODEM Programs…………………………………………..  28
  3045.  
  3046.  
  3047.  
  3048.  
  3049.  
  3050.  
  3051.  
  3052.  
  3053.  
  3054.  
  3055.  
  3056.  
  3057.  
  3058.  
  3059.  
  3060.  
  3061.                                       - i -
  3062.  
  3063.  
  3064.  
  3065.  
  3066.  
  3067.  
  3068.  
  3069.  
  3070.  
  3071.  
  3072.  
  3073.  
  3074.  
  3075.  
  3076.  
  3077.                                  LIST OF FIGURES
  3078.  
  3079.  
  3080.  
  3081.      Figure 1.  XMODEM-1k Blocks……………………………………  11
  3082.  
  3083.  
  3084.      Figure 2.  Mixed 1024 and 128 byte Blocks……………………….  11
  3085.  
  3086.  
  3087.      Figure 3.  YMODEM Batch Transmission Session…………………….  15
  3088.  
  3089.  
  3090.      Figure 4.  YMODEM Batch Transmission Session-1k Blocks……………  15
  3091.  
  3092.  
  3093.      Figure 5.  YMODEM Filename block transmitted by sz……………….  16
  3094.  
  3095.  
  3096.      Figure 6.  YMODEM Header Information and Features………………..  16
  3097.  
  3098.  
  3099.      Figure 7.  YMODEM-g Transmission Session………………………..  17
  3100.  
  3101.  
  3102.      Figure 8.  XMODEM Message Block Level Protocol…………………..  19
  3103.  
  3104.  
  3105.      Figure 9.  Data flow including Error Recovery……………………  20
  3106.  
  3107.  
  3108.     Figure 10.  Message Block Level Protocol, CRC mode………………..  22
  3109.  
  3110.  
  3111.     Figure 11.  Example of CRC Calculation written in C……………….  23
  3112.  
  3113.  
  3114.     Figure 12.  Data Flow: Receiver has CRC Option, Sender Doesn't……..  25
  3115.  
  3116.  
  3117.     Figure 13.  Receiver and Sender Both have CRC Option………………  26
  3118.  
  3119.  
  3120.  
  3121.  
  3122.  
  3123.  
  3124.  
  3125.  
  3126.  
  3127.  
  3128.  
  3129.  
  3130.  
  3131.  
  3132.  
  3133.  
  3134.  
  3135.  
  3136.  
  3137.  
  3138.  
  3139.  
  3140.  
  3141.  
  3142.                                       - ii -
  3143.  
  3144.  
  3145.  
  3146.  
  3147.